package com.cnswhy.cloud.server.comsumer.consumer;

import com.cnswhy.cloud.common.core.exception.BizException;
import com.cnswhy.cloud.common.core.mybatis.conditions.Wraps;
import com.cnswhy.cloud.common.core.utils.CnswhyUtil;
import com.cnswhy.cloud.common.core.utils.SystemClockUtil;
import com.cnswhy.cloud.common.redis.annotation.RedisLock;
import com.cnswhy.cloud.common.redis.service.IdGeneratorService;
import com.cnswhy.cloud.common.redis.service.RedisService;
import com.cnswhy.cloud.server.common.entity.enumeration.ExpressCompany;
import com.cnswhy.cloud.server.common.entity.enumeration.TransType;
import com.cnswhy.cloud.server.common.entity.enumeration.WalletType;
import com.cnswhy.cloud.server.common.entity.mq.SpellDayendCancelMsg;
import com.cnswhy.cloud.server.comsumer.event.BuybackOrderDayendEvent;
import com.cnswhy.cloud.server.comsumer.event.SpellDayendEvent;
import com.cnswhy.cloud.server.core.constant.RedisConstant;
import com.cnswhy.cloud.server.core.entity.*;
import com.cnswhy.cloud.server.core.oem.OemService;
import com.cnswhy.cloud.server.core.service.customer.CustomerPrivilegeService;
import com.cnswhy.cloud.server.core.service.customer.CustomerService;
import com.cnswhy.cloud.server.core.service.shop.ShopProductService;
import com.cnswhy.cloud.server.core.service.spell.BuyBackOrderService;
import com.cnswhy.cloud.server.core.service.spell.SpellOrderService;
import com.cnswhy.cloud.server.core.service.spell.SpellPriceService;
import com.cnswhy.cloud.server.core.shop.ProductStockService;
import com.cnswhy.cloud.server.core.wallet.WalletService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

@Component
@Slf4j
public class BuyBackOrderConsumer implements SpellDayendEvent, BuybackOrderDayendEvent {
    @Autowired
    IdGeneratorService idGeneratorService;
    @Autowired
    SpellOrderService spellOrderService;
    @Autowired
    WalletService walletService;
    @Autowired
    CustomerService customerService;
    @Autowired
    RedisService redisService;
    @Autowired
    ShopProductService shopProductService;
    @Autowired
    BuyBackOrderService buyBackOrderService;
    @Autowired
    ProductStockService productStockService;
    @Autowired
    OemService oemService;
    @Override
    @RedisLock(name = "BuyBackOrderConsumer")
    public void dayend(SpellDayendCancelMsg spellDayendCancelMsg) {
        SpellDayendCancelMsg spellDayendCancelMsg1 = (SpellDayendCancelMsg)redisService.get("BuyBackOrderConsumer" + spellDayendCancelMsg.getSettDate());
        if(spellDayendCancelMsg1 == null){
            redisService.set("BuyBackOrderConsumer" + spellDayendCancelMsg.getSettDate(),spellDayendCancelMsg,300L);
            buyBackOrder(spellDayendCancelMsg);
        }else{
        }
    }

    @Override
    @RedisLock(name = "BuyBackOrderConsumer")
    public void buyback(SpellDayendCancelMsg dayendCancelMsg) {
        SpellDayendCancelMsg spellDayendCancelMsg1 = (SpellDayendCancelMsg)redisService.get("BuyBackOrderConsumer" + dayendCancelMsg.getSettDate());
        if(spellDayendCancelMsg1 == null){
            redisService.set("BuyBackOrderConsumer" + dayendCancelMsg.getSettDate(),dayendCancelMsg,300L);
            buyBackOrder(dayendCancelMsg);
        }else{
        }
    }

    private void buyBackOrder(SpellDayendCancelMsg spellDayendCancelMsg){
    }
}
